{include file="public/layout" /}
 <form class="layui-form" action="">
     <input type="hidden" id="shipping_name" name="shipping_name" value="{$shipping_list[0]['shipping_name']}">
     <div class="layui-form-item">
		 <label class="layui-form-label">会员编号</label>
		 <div class="layui-input-inline layui-input-wrap" style="width: 700px;">
			 <table class="layui-table">
           		<tr>
           			<td>订单号：</td>
		            <td>{$order.order_sn}</td>
		            <td>下单时间：</td>
		            <td>{$order.add_time|date='Y-m-d H:i'}</td>
		            <td>物流公司：</td>
		            <td>
						<select id="shipping_code" name="shipping_code" onchange="set_shipping_name()" lay-filter="shipping_code">
							{foreach $shipping_list as $shipping}
		                 		<option  value="{$shipping.shipping_code}" >{$shipping.shipping_name}</option>
							{/foreach}
		         		</select>
         			</td>
			  	</tr>
			  	<tr>
	              	<td>配送费用：</td>
		            <td>{$order.shipping_price}</td>
		            <td>发货方式：</td>
		            <td>
		            	<select id="send_type" name="send_type" lay-filter="change_send">
		            		<option value="0">手填物流单号</option>
		            		<option value="3">无需物流</option>
		            	</select>
		            </td>
		            <td class="invoice">配送单号：</td>
		            <td class="invoice"><input class="layui-input" name="delivery_no" id="delivery_no" value="{$order.delivery_no}" ></td>
			   	</tr>
			 </table>
		 </div>
	 </div>

	 <div class="layui-form-item">
		 <label class="layui-form-label">收货信息</label>
		 <div class="layui-input-inline layui-input-wrap">
			 <table class="layui-table" style="width: 600px;">
				<tr>
					<td>收货人：</td>
					<td>{$order.consignee}</td>
				  	<td>电话：</td>
				  	<td>{$order.mobile}</td>
				</tr>
				<tr>
					<td>收货地址：</td>
					<td>{$order.address}</td>
					<td>用户备注：</td>
					<td>{$order.user_note}</td>
				</tr>
		  	</table>
        </div>
	 </div>
	 <input type="hidden" name="order_id" value="{$order.order_id}" id="order_id">
	 <div class="layui-form-item">
		 <div class="layui-input-block">
			 <button type="submit" class="layui-btn" lay-submit lay-filter="demo1">确认</button>
		 </div>
	 </div>
</form>
<script>
	layui.use(['form', 'laydate', 'util'], function(){
		var form = layui.form;
		var layer = layui.layer;
		var laydate = layui.laydate;
		var util = layui.util;

		// 提交事件
		form.on('submit(demo1)', function(data){
			var index = layer.load();
			layer.close(index);

			var field = data.field; // 获取表单字段值
			var order_id = $('#order_id').val();
			var admin_note = $('#note').val();
			$.ajax({
				type: "POST",
				url: "{:url('send')}",
				data: {
					order_id:order_id,
					shipping_code:$('#shipping_code').val(),
					delivery_no:$('#delivery_no').val(),
					admin_note:admin_note
				},
				success: function(res){
					console.log(res);
					if(res.status){
						layer.msg('提交成功');
					}else{
						layer.msg(res.msg);
					}
					setTimeout(function(){
						parent.layer.closeAll();
						parent.tableIns.reload()
					},1000)
				}
			});
			return false; // 阻止默认 form 跳转
		});
		form.on('select(shipping_code)', function(data){
			var shipping_name = othis.find("option:selected").text();
			$('#shipping_name').val(shipping_name);
		});
		form.on('radio(change_send)', function(data){
			var send_type = data.val();
			if(send_type == 0){
				$('.invoice').show();
			}else{
				$('.invoice').hide();
			}
		});

	});
</script>
<script type="text/javascript">
function set_shipping_name(){
	var shipping_name = $("#shipping_code").find("option:selected").text();
	$('#shipping_name').val(shipping_name);
}
</script>
</body>
</html>